
#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "SquidConverter.h"

class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};


class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title);

    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
    void OnConvert(wxCommandEvent& event);
private:
    DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(wxID_EXIT,  MyFrame::OnQuit)
    EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
    EVT_MENU(wxID_ANY,   MyFrame::OnConvert)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    if (!wxApp::OnInit())
        return false;

    MyFrame *frame = new MyFrame(_T("Squid FLV GUI"));
    frame->Show(true);

    return true;
}

MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title)
{
    wxMenu *fileMenu = new wxMenu;
    wxMenu *helpMenu = new wxMenu;
    helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"));
    fileMenu->Append(wxNewId(), _T("&Convert\tF2"));
    fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"));

    wxMenuBar *menuBar = new wxMenuBar();
    menuBar->Append(fileMenu, _T("&File"));
    menuBar->Append(helpMenu, _T("&Help"));
    SetMenuBar(menuBar);
}

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(true);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxMessageBox(wxString::Format(
        _T("Welcome to %s!\n\nThis is the minimal wxWidgets sample\n")
        _T("running under %s."), wxVERSION_STRING, wxGetOsDescription().c_str()),
        _T("About wxWidgets minimal sample"),
        wxOK | wxICON_INFORMATION,
        this);
}

void MyFrame::OnConvert(wxCommandEvent& WXUNUSED(event))
{
    ConvertToFLV(_T("TV.mpg"));
    
}
